package com.qdlc.p2p.biz.executer.impl;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.executer.BaseExecuter;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.constant.LogTplNid;
import com.qdlc.p2p.common.constant.NoticeTplNid;
import com.qdlc.p2p.dal.dto.Account;
import com.qdlc.p2p.dal.dto.AccountLog;

/**
 * 投标
 *
 * @author cx
 * @version 2.0
 * @since 2014-5-22
 */
@Service
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class BorrowTenderExcuter extends BaseExecuter {

    private String accountLogType = LogTplNid.TENDER_FREEZE;

    @Override
    public String getAccountLogType() {
        return accountLogType;
    }

    @Override
    public void addAccountLog() {
        Global.setTransfer("web_url", WEB_URL);
        Account account = accountDao.findByUserId(this.user.getUserId());
        AccountLog log = new AccountLog(super.user, accountLogType, super.toUser);
        log.setMoney(this.money);
        log.setTotal(account.getTotal());
        log.setUseMoney(account.getUseMoney());
        log.setNoUseMoney(account.getNoUseMoney());
        log.setCollection(account.getCollection());
        log.setRemark(this.getLogRemark());

        accountLogDao.save(log);
    }

    @Override
    public void handleNotice() {
        sendNotice(user, NoticeTplNid.TENDER);
    }
}
